<template>
  <div id="header">
    <div>
      <el-button @click="$store.commit('isCollapseFn', false)">展开</el-button>
      <el-button @click="$store.commit('isCollapseFn', true)">收起</el-button>
    </div>
    <el-dropdown @command="a" trigger="click">
      <span>欢迎 {{ user }}</span>
      <i class="el-icon-arrow-down el-icon--right"></i>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item command="exit" icon="iconfont icon-exit"
          >登出</el-dropdown-item
        >
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      user: "未定义用户",
    };
  },

  components: {},

  methods: {
    logoutFn() {
      this.$router.push({ path: "/login" });
    },
    a(item) {
      item == "exit" && this.$router.push({ path: "/login" });
    },
  },

  mounted() {},
  created() {
    this.user = sessionStorage.getItem("user");
  },
};
</script>

<style lang="scss" scoped>
#header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-left: 20px;
  border-bottom: 1px solid #ddd;
  .el-dropdown {
    margin-right: 20px;
    cursor: pointer;
  }
}
</style>